#include <stdio.h>
#include <fcntl.h>  
#include "Apisockcomm.h"

void main()
{
	int new_fd;
	int sd = RecvOpen(20000);
	
	while((new_fd=RecvAccept(sd))!= -1)
	{
		int pid;
		if( (pid = fork()) < 0)
			printf("fork error! \n");
		else if(pid == 0)
		{
			FRAME frame;
			memset(&frame, 0x00, sizeof(frame));
			frame.pBuf = (unsigned char*)malloc(4096);
			int			flags;
			flags = fcntl(new_fd, F_GETFL, 0);
			fcntl(new_fd, F_SETFL, flags | O_NONBLOCK);
			int ret = 0;
			int i =0;
			do{
				ret = RecvApi_nonb_1(new_fd, &frame);
				printf("step %d ret : %d\n", i++, ret);
				sleep(1);
			}while(ret);
		}
		else
		{
			continue;
		}
	}
}
